```html
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Spring框架深度解析 | 技术小馆</title>
    <link href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <link href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Hiragino Sans GB", Simsun, sans-serif;
            color: #333;
            line-height: 1.8;
        }
        h1, h2, h3, h4, h5, h6 {
            font-family: 'Noto Serif SC', serif;
            font-weight: 600;
            color: #2d3748;
        }
        .hero-gradient {
            background: linear-gradient(135deg, #6b46c1 0%, #805ad5 100%);
        }
        .code-block {
            background-color: #f7fafc;
            border-left: 4px solid #4299e1;
            padding: 1rem;
            overflow-x: auto;
        }
        .card-hover:hover {
            transform: translateY(-5px);
            box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
        }
        .concept-diagram {
            background: linear-gradient(145deg, #f7fafc, #edf2f7);
            border-radius: 12px;
            padding: 2rem;
        }
        .nav-link:hover {
            color: #6b46c1;
        }
        .nav-link.active {
            color: #6b46c1;
            border-bottom: 2px solid #6b46c1;
        }
        .timeline-item:before {
            content: '';
            position: absolute;
            left: -1.25rem;
            top: 0;
            width: 12px;
            height: 12px;
            border-radius: 50%;
            background-color: #6b46c1;
        }
    </style>
</head>
<body class="bg-gray-50">
    <!-- Hero Section -->
    <header class="hero-gradient text-white py-20">
        <div class="container mx-auto px-6 text-center">
            <h1 class="text-5xl font-bold mb-6 animate-fade-in">Spring框架深度解析</h1>
            <p class="text-xl opacity-90 max-w-3xl mx-auto mb-8">构建健壮、灵活、可扩展的企业级Java应用程序</p>
            <div class="flex justify-center space-x-4">
                <a href="#introduction" class="bg-white text-purple-700 px-6 py-3 rounded-full font-medium hover:bg-gray-100 transition duration-300">开始探索</a>
                <a href="#features" class="border-2 border-white text-white px-6 py-3 rounded-full font-medium hover:bg-white hover:text-purple-700 transition duration-300">核心特性</a>
            </div>
        </div>
    </header>

    <!-- Navigation -->
    <nav class="sticky top-0 bg-white shadow-sm z-10">
        <div class="container mx-auto px-6">
            <div class="flex justify-between items-center py-4">
                <a href="#" class="text-xl font-bold text-gray-800">Spring框架</a>
                <div class="hidden md:flex space-x-8">
                    <a href="#introduction" class="nav-link py-2">简介</a>
                    <a href="#architecture" class="nav-link py-2">架构</a>
                    <a href="#ioc" class="nav-link py-2">IoC</a>
                    <a href="#di" class="nav-link py-2">DI</a>
                    <a href="#aop" class="nav-link py-2">AOP</a>
                    <a href="#annotations" class="nav-link py-2">注解</a>
                </div>
                <button class="md:hidden text-gray-600">
                    <i class="fas fa-bars"></i>
                </button>
            </div>
        </div>
    </nav>

    <!-- Main Content -->
    <main class="container mx-auto px-6 py-12">
        <!-- Introduction Section -->
        <section id="introduction" class="mb-20">
            <div class="flex flex-col md:flex-row items-center gap-8">
                <div class="md:w-1/2">
                    <h2 class="text-3xl font-bold mb-6">什么是Spring框架？</h2>
                    <p class="text-lg mb-6 text-gray-700">在构建复杂的应用程序时，往往需要面对诸多繁琐的问题，比如依赖注入、面向切面编程、事务管理等等。而Spring框架，作为Java生态系统中最为流行和强大的开发框架之一，正是为了解决这些问题而诞生的。</p>
                    <p class="text-lg mb-6 text-gray-700">Spring框架不仅仅是一个简单的框架，更是一整套解决方案，为Java开发者提供了全方位的支持和便利。它的核心理念是轻量级、非侵入式和松耦合，通过提供丰富的模块化组件，帮助开发者构建健壮、灵活、可扩展的企业级应用程序。</p>
                    <div class="bg-blue-50 p-4 rounded-lg border-l-4 border-blue-500">
                        <p class="text-blue-800"><i class="fas fa-info-circle mr-2"></i>Spring框架通过其强大的功能和卓越的性能，已成为Java企业开发的事实标准。</p>
                    </div>
                </div>
                <div class="md:w-1/2 mt-8 md:mt-0">
                    <img src="https://cdn.nlark.com/yuque/0/2024/png/21449790/1715592036214-77a24c3a-41fe-4fcc-961f-9b3faec0ad7f.png" 
                         alt="Spring Framework" 
                         class="rounded-lg shadow-xl w-full h-auto object-cover">
                </div>
            </div>
        </section>

        <!-- Features Section -->
        <section id="features" class="mb-20">
            <h2 class="text-3xl font-bold mb-8 text-center">Spring框架的核心作用</h2>
            <div class="grid md:grid-cols-2 lg:grid-cols-3 gap-6">
                <div class="bg-white p-6 rounded-xl shadow-md card-hover transition duration-300">
                    <div class="text-purple-600 mb-4">
                        <i class="fas fa-project-diagram text-3xl"></i>
                    </div>
                    <h3 class="text-xl font-semibold mb-3">依赖注入</h3>
                    <p class="text-gray-600">通过依赖注入机制实现了组件之间的解耦，使得代码更加模块化、可复用，提高了代码的灵活性和可维护性。</p>
                </div>
                <div class="bg-white p-6 rounded-xl shadow-md card-hover transition duration-300">
                    <div class="text-blue-600 mb-4">
                        <i class="fas fa-code-branch text-3xl"></i>
                    </div>
                    <h3 class="text-xl font-semibold mb-3">面向切面编程</h3>
                    <p class="text-gray-600">通过AOP可以将应用程序的业务逻辑与横切关注点分离开来，提高了代码的重用性和可维护性。</p>
                </div>
                <div class="bg-white p-6 rounded-xl shadow-md card-hover transition duration-300">
                    <div class="text-green-600 mb-4">
                        <i class="fas fa-exchange-alt text-3xl"></i>
                    </div>
                    <h3 class="text-xl font-semibold mb-3">声明式事务管理</h3>
                    <p class="text-gray-600">提供了简单而强大的声明式事务管理功能，通过简单的配置即可实现事务的管理，避免了繁琐的编程式事务管理。</p>
                </div>
                <div class="bg-white p-6 rounded-xl shadow-md card-hover transition duration-300">
                    <div class="text-yellow-600 mb-4">
                        <i class="fas fa-plug text-3xl"></i>
                    </div>
                    <h3 class="text-xl font-semibold mb-3">简化JEE开发</h3>
                    <p class="text-gray-600">提供了对JEE开发的简化和优化，使开发者可以更轻松地构建各种类型的企业应用。</p>
                </div>
                <div class="bg-white p-6 rounded-xl shadow-md card-hover transition duration-300">
                    <div class="text-red-600 mb-4">
                        <i class="fas fa-puzzle-piece text-3xl"></i>
                    </div>
                    <h3 class="text-xl font-semibold mb-3">框架集成</h3>
                    <p class="text-gray-600">提供了与其他框架和技术的集成支持，使得开发者可以轻松地集成这些技术到Spring应用中。</p>
                </div>
                <div class="bg-white p-6 rounded-xl shadow-md card-hover transition duration-300">
                    <div class="text-indigo-600 mb-4">
                        <i class="fas fa-building text-3xl"></i>
                    </div>
                    <h3 class="text-xl font-semibold mb-3">企业级开发</h3>
                    <p class="text-gray-600">提供了丰富的企业级功能，包括远程调用、消息传递、安全认证、批处理等，帮助开发者快速构建复杂的企业级应用。</p>
                </div>
            </div>
        </section>

        <!-- Architecture Section -->
        <section id="architecture" class="mb-20">
            <h2 class="text-3xl font-bold mb-8 text-center">Spring架构组成</h2>
            <div class="concept-diagram mb-8">
                <img src="https://cdn.nlark.com/yuque/0/2024/png/21449790/1715659298601-f74f2940-a910-4fd7-b721-16c527afda90.png" 
                     alt="Spring Architecture" 
                     class="mx-auto rounded-lg shadow-md">
            </div>
            <div class="grid md:grid-cols-2 gap-6">
                <div>
                    <h3 class="text-2xl font-semibold mb-4 text-purple-700">核心容器</h3>
                    <p class="mb-4">核心容器是Spring框架的基础，包括了Spring的核心功能，如依赖注入和面向切面编程。</p>
                    <ul class="space-y-2">
                        <li class="flex items-start">
                            <i class="fas fa-check-circle text-green-500 mt-1 mr-2"></i>
                            <span><strong>Beans模块</strong>：提供了Spring框架的基本构建块，包括BeanFactory和ApplicationContext等接口</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-check-circle text-green-500 mt-1 mr-2"></i>
                            <span><strong>Core模块</strong>：提供了Spring框架的核心功能，包括依赖注入、事件监听、资源加载等</span>
                        </li>
                    </ul>
                </div>
                <div>
                    <h3 class="text-2xl font-semibold mb-4 text-blue-700">其他关键模块</h3>
                    <div class="grid grid-cols-2 gap-4">
                        <div>
                            <h4 class="font-medium mb-2">数据访问/集成</h4>
                            <p class="text-sm text-gray-600">与数据库访问和集成相关的功能</p>
                        </div>
                        <div>
                            <h4 class="font-medium mb-2">Web模块</h4>
                            <p class="text-sm text-gray-600">构建Web应用程序的支持</p>
                        </div>
                        <div>
                            <h4 class="font-medium mb-2">AOP模块</h4>
                            <p class="text-sm text-gray-600">面向切面编程的支持</p>
                        </div>
                        <div>
                            <h4 class="font-medium mb-2">消息模块</h4>
                            <p class="text-sm text-gray-600">与消息传递相关的功能</p>
                        </div>
                        <div>
                            <h4 class="font-medium mb-2">测试模块</h4>
                            <p class="text-sm text-gray-600">单元测试和集成测试的支持</p>
                        </div>
                    </div>
                </div>
            </div>
        </section>

        <!-- Quick Start Section -->
        <section class="mb-20 bg-gray-50 p-8 rounded-xl">
            <h2 class="text-3xl font-bold mb-6 text-center">快速搭建Spring环境</h2>
            <div class="max-w-4xl mx-auto">
                <div class="mb-8">
                    <h3 class="text-xl font-semibold mb-4 flex items-center">
                        <span class="bg-purple-100 text-purple-800 rounded-full w-8 h-8 flex items-center justify-center mr-3">1</span>
                        添加Spring依赖
                    </h3>
                    <div class="code-block">
                        <pre><code class="language-xml">&lt;dependency&gt;
    &lt;groupId&gt;org.springframework&lt;/groupId&gt;
    &lt;artifactId&gt;spring-context&lt;/artifactId&gt;
    &lt;version&gt;6.1.6&lt;/version&gt;
&lt;/dependency&gt;</code></pre>
                    </div>
                </div>
                
                <div class="mb-8">
                    <h3 class="text-xl font-semibold mb-4 flex items-center">
                        <span class="bg-purple-100 text-purple-800 rounded-full w-8 h-8 flex items-center justify-center mr-3">2</span>
                        编写Spring配置文件
                    </h3>
                    <div class="code-block">
                        <pre><code class="language-xml">&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://www.springframework.org/schema/beans 
       http://www.springframework.org/schema/beans/spring-beans.xsd"&gt;

    &lt;bean id="helloBean" class="com.ts.HelloWorld"&gt;
        &lt;property name="message" value="Hello, Spring!" /&gt;
    &lt;/bean&gt;
&lt;/beans&gt;</code></pre>
                    </div>
                </div>
                
                <div class="mb-8">
                    <h3 class="text-xl font-semibold mb-4 flex items-center">
                        <span class="bg-purple-100 text-purple-800 rounded-full w-8 h-8 flex items-center justify-center mr-3">3</span>
                        编写Java代码
                    </h3>
                    <div class="code-block">
                        <pre><code class="language-java">package com.ts;

import lombok.Data;

@Data
public class HelloWorld {
    private String message;
}</code></pre>
                    </div>
                </div>
                
                <div>
                    <h3 class="text-xl font-semibold mb-4 flex items-center">
                        <span class="bg-purple-100 text-purple-800 rounded-full w-8 h-8 flex items-center justify-center mr-3">4</span>
                        运行项目
                    </h3>
                    <div class="code-block">
                        <pre><code class="language-java">import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class SpringTest {
    public static void main(String[] args) {
        ApplicationContext context = 
            new ClassPathXmlApplicationContext("applicationContext.xml");
        HelloWorld obj = (HelloWorld) context.getBean("helloBean");
        System.out.println(obj.getMessage());
    }
}</code></pre>
                    </div>
                </div>
            </div>
        </section>

        <!-- IOC Section -->
        <section id="ioc" class="mb-20">
            <h2 class="text-3xl font-bold mb-8 text-center">Spring IoC思想</h2>
            <div class="flex flex-col md:flex-row gap-8 mb-12">
                <div class="md:w-1/2">
                    <h3 class="text-2xl font-semibold mb-4 text-purple-700">什么是控制反转？</h3>
                    <p class="mb-4">控制反转（IoC）是一种设计原则，它将对象的控制权从应用程序代码中转移到一个容器（在Spring中就是Spring IoC容器）。这意味着对象的创建、配置、管理和生命周期由容器来负责，而不是由应用程序代码显式地控制。</p>
                    <p class="mb-4">Spring IoC容器负责管理Spring应用程序中对象的创建、配置和生命周期。容器读取配置元数据（通常是XML配置文件或基于注解的配置），并根据这些配置来创建和管理对象。</p>
                    <div class="bg-yellow-50 border-l-4 border-yellow-400 p-4 mb-4">
                        <p class="text-yellow-800"><i class="fas fa-lightbulb mr-2"></i>IoC容器主要有两种接口：BeanFactory和ApplicationContext，后者是前者的子接口，提供了更多企业级功能。</p>
                    </div>
                </div>
                <div class="md:w-1/2">
                    <div class="bg-white p-6 rounded-xl shadow-md">
                        <h4 class="text-lg font-semibold mb-4 text-blue-700">传统方式 vs IoC方式</h4>
                        <div class="mb-4">
                            <h5 class="font-medium mb-2">传统强耦合方式</h5>
                            <div class="code-block">
                                <pre><code class="language-java">public class UserServiceImpl {
    private UserDAO userDAO = new UserDAOImpl();
    
    public User queryUser() {
        return userDAO.queryUser();
    }
}</code></pre>
                            </div>
                        </div>
                        <div>
                            <h5 class="font-medium mb-2">IoC解耦方式</h5>
                            <div class="code-block">
                                <pre><code class="language-xml">&lt;bean id="userDao" class="com.ts.UserDao"&gt;&lt;/bean&gt;
&lt;bean id="userService" class="com.ts.UserService"&gt;
    &lt;property name="userDao" ref="userDao"/&gt;
&lt;/bean&gt;</code></pre>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <div class="grid md:grid-cols-3 gap-6">
                <div class="bg-white p-6 rounded-xl shadow-md card-hover">
                    <h3 class="text-xl font-semibold mb-4 text-center">Bean作用域</h3>
                    <div class="mb-4">
                        <h4 class="font-medium mb-2 text-purple-600">单例(Singleton)</h4>
                        <p class="text-sm text-gray-600">默认作用域，容器中只存在一个实例</p>
                        <div class="code-block mt-2">
                            <pre><code class="language-xml">&lt;bean scope="singleton"/&gt;</code></pre>
                        </div>
                    </div>
                    <div>
                        <h4 class="font-medium mb-2 text-blue-600">原型(Prototype)</h4>
                        <p class="text-sm text-gray-600">每次请求都会创建一个新实例</p>
                        <div class="code-block mt-2">
                            <pre><code class="language-xml">&lt;bean scope="prototype"/&gt;</code></pre>
                        </div>
                    </div>
                </div>
                <div class="bg-white p-6 rounded-xl shadow-md card-hover">
                    <h3 class="text-xl font-semibold mb-4 text-center">Bean生命周期</h3>
                    <div class="space-y-2">
                        <div class="flex items-start">
                            <span class="bg-gray-200 text-gray-800 rounded-full w-6 h-6 flex items-center justify-center text-sm mr-2">1</span>
                            <span>实例化</span>
                        </div>
                        <div class="flex items-start">
                            <span class="bg-gray-200 text-gray-800 rounded-full w-6 h-6 flex items-center justify-center text-sm mr-2">2</span>
                            <span>属性设置</span>
                        </div>
                        <div class="flex items-start">
                            <span class="bg-gray-200 text-gray-800 rounded-full w-6 h-6 flex items-center justify-center text-sm mr-2">3</span>
                            <span>初始化</span>
                        </div>
                        <div class="flex items-start">
                            <span class="bg-gray-200 text-gray-800 rounded-full w-6 h-6 flex items-center justify-center text-sm mr-2">4</span>
                            <span>销毁</span>
                        </div>
                    </div>
                    <div class="code-block mt-4">
                        <pre><code class="language-xml">&lt;bean init-method="init" 
      destroy-method="cleanup"/&gt;</code></pre>
                    </div>
                </div>
                <div class="bg-white p-6 rounded-xl shadow-md card-hover">
                    <h3 class="text-xl font-semibold mb-4 text-center">初始化方式</h3>
                    <div class="mb-4">
                        <h4 class="font-medium mb-2 text-green-600">饿汉式</h4>
                        <p class="text-sm text-gray-600">默认方式，容器启动时立即实例化</p>
                    </div>
                    <div>
                        <h4 class="font-medium mb-2 text-red-600">懒加载</h4>
                        <p class="text-sm text-gray-600">首次请求时才实例化</p>
                        <div class="code-block mt-2">
                            <pre><code class="language-xml">&lt;bean lazy-init="true"/&gt;</code></pre>
                        </div>
                    </div>
                </div>
            </div>
        </section>

        <!-- DI Section -->
        <section id="di" class="mb-20">
            <h2 class="text-3xl font-bold mb-8 text-center">Spring DI思想</h2>
            <div class="bg-blue-50 rounded-xl p-8 mb-12">
                <h3 class="text-2xl font-semibold mb-4 text-blue-700">什么是依赖注入？</h3>
                <p class="mb-4">依赖注入是一种设计模式，用于实现控制反转，它将对象所依赖的其他对象的创建和管理职责交由容器来处理。简单来说，DI是通过将对象的依赖通过注入方式（如构造器、Setter方法或字段注入）传递给对象，而不是让对象自己去创建或查找它的依赖。</p>
                <div class="grid md:grid-cols-3 gap-6 mt-6">
                    <div class="bg-white p-4 rounded-lg shadow-sm">
                        <h4 class="font-semibold mb-2 text-purple-600 flex items-center">
                            <i class="fas fa-wrench mr-2"></i>构造器注入
                        </h4>
                        <div class="code-block">
                            <pre><code class="language-xml">&lt;bean id="userService" class="com.ts.UserService"&gt;
    &lt;constructor-arg ref="userDao"/&gt;
&lt;/bean&gt;</code></pre>
                        </div>
                    </div>
                    <div class="bg-white p-4 rounded-lg shadow-sm">
                        <h4 class="font-semibold mb-2 text-blue-600 flex items-center">
                            <i class="fas fa-cog mr-2"></i>Setter方法注入
                        </h4>
                        <div class="code-block">
                            <pre><code class="language-xml">&lt;bean id="userService" class="com.ts.UserService"&gt;
    &lt;property name="userDao" ref="userDao"/&gt;
&lt;/bean&gt;</code></pre>
                        </div>
                    </div>
                    <div class="bg-white p-4 rounded-lg shadow-sm">
                        <h4 class="font-semibold mb-2 text-green-600 flex items-center">
                            <i class="fas fa-tag mr-2"></i>字段注入
                        </h4>
                        <div class="code-block">
                            <pre><code class="language-java">@Autowired
private UserDao userDao;</code></pre>
                        </div>
                    </div>
                </div>
            </div>

            <h3 class="text-2xl font-semibold mb-6 text-center">依赖注入的多种方式</h3>
            <div class="grid md:grid-cols-2 gap-8">
                <div>
                    <h4 class="text-xl font-medium mb-4 text-purple-700">注入对象引用</h4>
                    <div class="code-block mb-6">
                        <pre><code class="language-xml">&lt;bean id="userDao" class="com.ts.UserDao"/&gt;

&lt;bean id="userService" class="com.ts.UserService"&gt;
    &lt;property name="userDao" ref="userDao"/&gt;
&lt;/bean&gt;</code></pre>
                    </div>
                    
                    <h4 class="text-xl font-medium mb-4 text-blue-700">注入集合类型</h4>
                    <div class="code-block">
                        <pre><code class="language-xml">&lt;bean id="user" class="com.ts.User"&gt;
    &lt;property name="emails"&gt;
        &lt;list&gt;
            &lt;value&gt;admin@qq.com&lt;/value&gt;
            &lt;value&gt;admin@163.com&lt;/value&gt;
        &lt;/list&gt;
    &lt;/property&gt;
    &lt;property name="phones"&gt;
        &lt;set&gt;
            &lt;value&gt;10086&lt;/value&gt;
        &lt;/set&gt;
    &lt;/property&gt;
    &lt;property name="map"&gt;
        &lt;map&gt;
            &lt;entry key="k1" value="v1"/&gt;
        &lt;/map&gt;
    &lt;/property&gt;
&lt;/bean&gt;</code></pre>
                    </div>
                </div>
                <div>
                    <h4 class="text-xl font-medium mb-4 text-green-700">注入文本值</h4>
                    <div class="code-block">
                        <pre><code class="language-xml">&lt;bean id="user" class="com.ts.User"&gt;
    &lt;property name="id" value="10"/&gt;
    &lt;property name="name" value="admin"/&gt;
    &lt;property name="birthday" value="2024/05/14"/&gt;
&lt;/bean&gt;</code></pre>
                    </div>
                    
                    <h4 class="text-xl font-medium mt-8 mb-4 text-red-700">DI的优点</h4>
                    <ul class="space-y-3">
                        <li class="flex items-start">
                            <i class="fas fa-check-circle text-green-500 mt-1 mr-2"></i>
                            <span><strong>松耦合</strong>：组件之间的依赖关系由容器管理，代码更加松耦合</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-check-circle text-green-500 mt-1 mr-2"></i>
                            <span><strong>可测试性</strong>：可以轻松地使用模拟对象进行单元测试</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-check-circle text-green-500 mt-1 mr-2"></i>
                            <span><strong>灵活性</strong>：通过容器配置可以灵活地更改依赖对象的实现</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-check-circle text-green-500 mt-1 mr-2"></i>
                            <span><strong>集中管理</strong>：依赖关系和配置集中管理，代码更加简洁</span>
                        </li>
                    </ul>
                </div>
            </div>
        </section>

        <!-- AOP Section -->
        <section id="aop" class="mb-20">
            <h2 class="text-3xl font-bold mb-8 text-center">Spring AOP思想</h2>
            <div class="bg-purple-50 rounded-xl p-8 mb-12">
                <h3 class="text-2xl font-semibold mb-4 text-purple-700">面向切面编程概述</h3>
                <p class="mb-4">Spring AOP（面向切面编程，Aspect-Oriented Programming）是一种编程范式，旨在通过分离应用程序中的关注点来提高模块化和代码重用性。它允许开发者将跨领域的关注点（如日志记录、安全、事务管理等）从业务逻辑中分离出来，以实现更清晰、更易维护的代码结构。</p>
                
                <div class="grid md:grid-cols-2 gap-8 mt-8">
                    <div>
                        <h4 class="text-xl font-medium mb-4 text-blue-700">核心概念</h4>
                        <div class="space-y-4">
                            <div>
                                <h5 class="font-medium mb-1">Aspect（切面）</h5>
                                <p class="text-sm text-gray-600">将跨领域关注点封装在可重用的模块中</p>
                            </div>
                            <div>
                                <h5 class="font-medium mb-1">Join Point（连接点）</h5>
                                <p class="text-sm text-gray-600">程序执行中可以插入切面的具体点</p>
                            </div>
                            <div>
                                <h5 class="font-medium mb-1">Advice（通知）</h5>
                                <p class="text-sm text-gray-600">在特定连接点上执行的代码</p>
                            </div>
                            <div>
                                <h5 class="font-medium mb-1">Pointcut（切入点）</h5>
                                <p class="text-sm text-gray-600">定义哪些连接点应用通知的表达式</p>
                            </div>
                        </div>
                    </div>
                    <div>
                        <h4 class="text-xl font-medium mb-4 text-green-700">通知类型</h4>
                        <div class="space-y-4">
                            <div>
                                <h5 class="font-medium mb-1">@Before</h5>
                                <p class="text-sm text-gray-600">在方法执行之前执行</p>
                            </div>
                            <div>
                                <h5 class="font-medium mb-1">@After</h5>
                                <p class="text-sm text-gray-600">在方法执行之后执行</p>
                            </div>
                            <div>
                                <h5 class="font-medium mb-1">@AfterReturning</h5>
                                <p class="text-sm text-gray-600">在方法成功执行之后执行</p>
                            </div>
                            <div>
                                <h5 class="font-medium mb-1">@Around</h5>
                                <p class="text-sm text-gray-600">包围连接点的通知</p>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <div class="grid md:grid-cols-2 gap-8">
                <div>
                    <h3 class="text-2xl font-semibold mb-6 text-purple-700">AOP配置示例</h3>
                    <div class="mb-6">
                        <h4 class="font-medium mb-2">1. 导入依赖</h4>
                        <div class="code-block">
                            <pre><code class="language-xml">&lt;dependency&gt;
    &lt;groupId&gt;org.springframework&lt;/groupId&gt;
    &lt;artifactId&gt;spring-aop&lt;/artifactId&gt;
    &lt;version&gt;6.1.6&lt;/version&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
    &lt;groupId&gt;org.springframework&lt;/groupId&gt;
    &lt;artifactId&gt;spring-aspects&lt;/artifactId&gt;
    &lt;version&gt;6.1.6&lt;/version&gt;
&lt;/dependency&gt;</code></pre>
                        </div>
                    </div>
                    
                    <div class="mb-6">
                        <h4 class="font-medium mb-2">2. 定义通知</h4>
                        <div class="code-block">
                            <pre><code class="language-java">public class MyMethodBeforeAdvice 
    implements MethodBeforeAdvice {
    
    public void before(Method method, Object[] args, Object target) {
        System.out.println("before advice executed...");
    }
}</code></pre>
                        </div>
                    </div>
                    
                    <div>
                        <h4 class="font-medium mb-2">3. XML配置</h4>
                        <div class="code-block">
                            <pre><code class="language-xml">&lt;aop:config&gt;
    &lt;aop:pointcut id="p1" 
        expression="execution(public * com.ts.*.*(..))"/&gt;
    &lt;aop:advisor advice-ref="methodBeforeAdvice" 
        pointcut-ref="p1"/&gt;
&lt;/aop:config&gt;</code></pre>
                        </div>
                    </div>
                </div>
                <div>
                    <h3 class="text-2xl font-semibold mb-6 text-blue-700">execution表达式</h3>
                    <div class="mb-6">
                        <h4 class="font-medium mb-2">基本语法</h4>
                        <div class="bg-gray-800 text-gray-100 p-4 rounded-lg">
                            <pre><code>execution(modifiers-pattern? 
          return-type-pattern 
          declaring-type-pattern? 
          method-name-pattern(param-pattern) 
          throws-pattern?)</code></pre>
                        </div>
                    </div>
                    
                    <div class="mb-6">
                        <h4 class="font-medium mb-2">常用表达式示例</h4>
                        <div class="space-y-3">
                            <div>
                                <p class="text-sm font-medium">匹配包下所有类的所有方法</p>
                                <div class="code-block">
                                    <pre><code class="language-xml">execution(* com.ts.aaron.aop..*.*(..))</code></pre>
                                </div>
                            </div>
                            <div>
                                <p class="text-sm font-medium">匹配特定类的方法</p>
                                <div class="code-block">
                                    <pre><code class="language-xml">execution(* com.ts.UserService.*(..))</code></pre>
                                </div>
                            </div>
                            <div>
                                <p class="text-sm font-medium">匹配特定方法名</p>
                                <div class="code-block">
                                    <pre><code class="language-xml">execution(* save(..))</code></pre>
                                </div>
                            </div>
                        </div>
                    </div>
                    
                    <h3 class="text-2xl font-semibold mb-4 text-green-700">AOP实现原理</h3>
                    <div class="bg-white p-4 rounded-lg shadow-sm">
                        <div class="flex items-start mb-4">
                            <div class="bg-blue-100 text-blue-800 rounded-full w-10 h-10 flex items-center justify-center mr-3">JDK</div>
                            <div>
                                <h4 class="font-medium">JDK动态代理</h4>
                                <p class="text-sm text-gray-600">基于接口的代理，要求目标对象实现接口</p>
                            </div>
                        </div>
                        <div class="flex items-start">
                            <div class="bg-green-100 text-green-800 rounded-full w-10 h-10 flex items-center justify-center mr-3">CGLIB</div>
                            <div>
                                <h4 class="font-medium">CGLIB代理</h4>
                                <p class="text-sm text-gray-600">基于类的代理，通过生成子类实现</p>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </section>

        <!-- Annotations Section -->
        <section id="annotations" class="mb-20">
            <h2 class="text-3xl font-bold mb-8 text-center">Spring注解驱动开发</h2>
            <div class="bg-gray-50 rounded-xl p-8 mb-12">
                <h3 class="text-2xl font-semibold mb-4 text-purple-700">注解的优势</h3>
                <div class="grid md:grid-cols-2 lg:grid-cols-3 gap-6">
                    <div class="bg-white p-4 rounded-lg shadow-sm">
                        <div class="text-blue-500 mb-2">
                            <i class="fas fa-code text-2xl"></i>
                        </div>
                        <h4 class="font-medium mb-1">简化配置</h4>
                        <p class="text-sm text-gray-600">减少XML配置，使代码更简洁</p>
                    </div>
                    <div class="bg-white p-4 rounded-lg shadow-sm">
                        <div class="text-green-500 mb-2">
                            <i class="fas fa-book-open text-2xl"></i>
                        </div>
                        <h4 class="font-medium mb-1">提高可读性</h4>
                        <p class="text-sm text-gray-600">直接在代码中表明组件的作用</p>
                    </div>
                    <div class="bg-white p-4 rounded-lg shadow-sm">
                        <div class="text-purple-500 mb-2">
                            <i class="fas fa-cogs text-2xl"></i>
                        </div>
                        <h4 class="font-medium mb-1">自动装配</h4>
                        <p class="text-sm text-gray-600">@Autowired实现依赖自动注入</p>
                    </div>
                    <div class="bg-white p-4 rounded-lg shadow-sm">
                        <div class="text-yellow-500 mb-2">
                            <i class="fas fa-layer-group text-2xl"></i>
                        </div>
                        <h4 class="font-medium mb-1">组件管理</h4>
                        <p class="text-sm text-gray-600">@Component等注解管理Bean</p>
                    </div>
                    <div class="bg-white p-4 rounded-lg shadow-sm">
                        <div class="text-red-500 mb-2">
                            <i class="fas fa-bolt text-2xl"></i>
                        </div>
                        <h4 class="font-medium mb-1">开发效率</h4>
                        <p class="text-sm text-gray-600">减少样板代码，提高效率</p>
                    </div>
                </div>
            </div>

            <div class="grid md:grid-cols-3 gap-8">
                <div>
                    <h3 class="text-2xl font-semibold mb-6 text-blue-700">核心注解</h3>
                    <div class="space-y-4">
                        <div class="bg-white p-4 rounded-lg shadow-sm">
                            <h4 class="font-medium mb-1 text-purple-600">@Component</h4>
                            <p class="text-sm text-gray-600">通用的组件注解</p>
                        </div>
                        <div class="bg-white p-4 rounded-lg shadow-sm">
                            <h4 class="font-medium mb-1 text-blue-600">@Service</h4>
                            <p class="text-sm text-gray-600">服务层组件</p>
                        </div>
                        <div class="bg-white p-4 rounded-lg shadow-sm">
                            <h4 class="font-medium mb-1 text-green-600">@Repository</h4>
                            <p class="text-sm text-gray-600">数据访问层组件</p>
                        </div>
                        <div class="bg-white p-4 rounded-lg shadow-sm">
                            <h4 class="font-medium mb-1 text-red-600">@Controller</h4>
                            <p class="text-sm text-gray-600">控制层组件</p>
                        </div>
                        <div class="bg-white p-4 rounded-lg shadow-sm">
                            <h4 class="font-medium mb-1 text-yellow-600">@Autowired</h4>
                            <p class="text-sm text-gray-600">自动装配依赖</p>
                        </div>
                    </div>
                </div>
                
                <div>
                    <h3 class="text-2xl font-semibold mb-6 text-purple-700">AOP注解</h3>
                    <div class="space-y-4">
                        <div class="bg-white p-4 rounded-lg shadow-sm">
                            <h4 class="font-medium mb-1 text-blue-600">@Aspect</h4>
                            <p class="text-sm text-gray-600">声明切面类</p>
                        </div>
                        <div class="bg-white p-4 rounded-lg shadow-sm">
                            <h4 class="font-medium mb-1 text-purple-600">@Pointcut</h4>
                            <p class="text-sm text-gray-600">定义切入点</p>
                        </div>
                        <div class="bg-white p-4 rounded-lg shadow-sm">
                            <h4 class="font-medium mb-1 text-green-600">@Before</h4>
                            <p class="text-sm text-gray-600">前置通知</p>
                        </div>
                        <div class="bg-white p-4 rounded-lg shadow-sm">
                            <h4 class="font-medium mb-1 text-red-600">@After</h4>
                            <p class="text-sm text-gray-600">后置通知</p>
                        </div>
                        <div class="bg-white p-4 rounded-lg shadow-sm">
                            <h4 class="font-medium mb-1 text-yellow-600">@Around</h4>
                            <p class="text-sm text-gray-600">环绕通知</p>
                        </div>
                    </div>
                </div>
                
                <div>
                    <h3 class="text-2xl font-semibold mb-6 text-green-700">事务注解</h3>
                    <div class="space-y-4">
                        <div class="bg-white p-4 rounded-lg shadow-sm">
                            <h4 class="font-medium mb-1 text-blue-600">@Transactional</h4>
                            <p class="text-sm text-gray-600">声明事务管理</p>
                        </div>
                        <div class="bg-white p-4 rounded-lg shadow-sm">
                            <h4 class="font-medium mb-1 text-purple-600">@EnableTransactionManagement</h4>
                            <p class="text-sm text-gray-600">启用事务管理</p>
                        </div>
                        <div class="bg-white p-4 rounded-lg shadow-sm">
                            <h4 class="font-medium mb-1 text-green-600">propagation</h4>
                            <p class="text-sm text-gray-600">事务传播行为</p>
                        </div>
                        <div class="bg-white p-4 rounded-lg shadow-sm">
                            <h4 class="font-medium mb-1 text-red-600">isolation</h4>
                            <p class="text-sm text-gray-600">事务隔离级别</p>
                        </div>
                    </div>
                </div>
            </div>

            <h3 class="text-2xl font-semibold mt-12 mb-6 text-center">注解配置示例</h3>
            <div class="grid md:grid-cols-2 gap-8">
                <div>
                    <h4 class="text-xl font-medium mb-4 text-purple-700">1. 定义Bean对象</h4>
                    <div class="code-block">
                        <pre><code class="language-java">@Component
@Data
public class MyBean {
    @Value("toString")
    private String name;
    
    @Value("20")
    private int age;
}</code></pre>
                    </div>
                </div>
                <div>
                    <h4 class="text-xl font-medium mb-4 text-blue-700">2. 自动注入</h4>
                    <div class="code-block">
                        <pre><code class="language-java">@Service
public class MyService {
    @Autowired
    private MyBean myBean;

    public void doSomething() {
        System.out.println(myBean);
    }
}</code></pre>
                    </div>
                </div>
                <div>
                    <h4 class="text-xl font-medium mb-4 text-green-700">3. XML开启包扫描</h4>
                    <div class="code-block">
                        <pre><code class="language-xml">&lt;context:component-scan 
    base-package="com.ts.anno"/&gt;</code></pre>
                    </div>
                </div>
                <div>
                    <h4 class="text-xl font-medium mb-4 text-red-700">4. 测试</h4>
                    <div class="code-block">
                        <pre><code class="language-java">ApplicationContext context = 
    new ClassPathXmlApplicationContext(
        "classpath:applicationContext.xml");
MyService myService = context.getBean(
    "myService", MyService.class);
myService.doSomething();</code></pre>
                    </div>
                </div>
            </div>
        </section>

        <!-- Transaction Section -->
        <section class="mb-20">
            <h2 class="text-3xl font-bold mb-8 text-center">Spring事务管理</h2>
            <div class="bg-gray-50 rounded-xl p-8 mb-12">
                <h3 class="text-2xl font-semibold mb-4 text-purple-700">事务管理概述</h3>
                <p class="mb-4">在企业级应用开发中，事务管理是确保数据一致性和系统可靠性的关键技术。Spring提供了一套功能强大且易于使用的事务管理机制，包括声明式事务和编程式事务两种方式。</p>
                
                <div class="grid md:grid-cols-2 gap-8 mt-8">
                    <div>
                        <h4 class="text-xl font-medium mb-4 text-blue-700">声明式事务</h4>
                        <p class="mb-4">通过注解或XML配置来定义事务边界，无需在业务代码中直接处理事务控制逻辑。</p>
                        <div class="code-block">
                            <pre><code class="language-java">@Transactional
public void transferMoney(Account from, 
                         Account to, 
                         double amount) {
    // 业务逻辑
}</code></pre>
                        </div>
                    </div>
                    <div>
                        <h4 class="text-xl font-medium mb-4 text-green-700">编程式事务</h4>
                        <p class="mb-4">通过TransactionTemplate或PlatformTransactionManager接口进行更灵活的事务控制。</p>
                        <div class="code-block">
                            <pre><code class="language-java">transactionTemplate.execute(status -> {
    // 业务逻辑
    return result;
});</code></pre>
                        </div>
                    </div>
                </div>
            </div>

            <h3 class="text-2xl font-semibold mb-6 text-center">事务配置示例</h3>
            <div class="grid md:grid-cols-2 gap-8">
                <div>
                    <h4 class="text-xl font-medium mb-4 text-purple-700">1. 导入依赖</h4>
                    <div class="code-block">
                        <pre><code class="language-xml">&lt;dependency&gt;
    &lt;groupId&gt;org.springframework&lt;/groupId&gt;
    &lt;artifactId&gt;spring-tx&lt;/artifactId&gt;
    &lt;version&gt;6.1.6&lt;/version&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
    &lt;groupId&gt;com.alibaba&lt;/groupId&gt;
    &lt;artifactId&gt;druid&lt;/artifactId&gt;
    &lt;version&gt;1.2.14&lt;/version&gt;
&lt;/dependency&gt;</code></pre>
                    </div>
                </div>
                <div>
                    <h4 class="text-xl font-medium mb-4 text-blue-700">2. 事务管理代码</h4>
                    <div class="code-block">
                        <pre><code class="language-java">@Service
public class UserService {
    @Autowired
    private JdbcTemplate jdbcTemplate;

    @Transactional
    public void add(String name) {
        jdbcTemplate.update("INSERT INTO t_User VALUES(?)", name);
        int x = 10 / 0; // 模拟异常
        jdbcTemplate.update("INSERT INTO t_User VALUES(?)", name);
    }
}</code></pre>
                    </div>
                </div>
                <div>
                    <h4 class="text-xl font-medium mb-4 text-green-700">3. XML配置</h4>
                    <div class="code-block">
                        <pre><code class="language-xml">&lt;!-- 数据源 --&gt;
&lt;bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource"&gt;
    &lt;property name="url" value="jdbc:mysql://..."/&gt;
    &lt;property name="username" value="root"/&gt;
    &lt;property name="password" value="root"/&gt;
&lt;/bean&gt;

&lt;!-- 事务管理器 --&gt;
&lt;bean id="transactionManager" 
    class="org.springframework.jdbc.datasource.DataSourceTransactionManager"&gt;
    &lt;property name="dataSource" ref="dataSource"/&gt;
&lt;/bean&gt;

&lt;!-- 启用注解事务 --&gt;
&lt;tx:annotation-driven transaction-manager="transactionManager"/&gt;</code></pre>
                    </div>
                </div>
                <div>
                    <h4 class="text-xl font-medium mb-4 text-red-700">4. 测试</h4>
                    <div class="code-block">
                        <pre><code class="language-java">@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("classpath:applicationContext.xml")
public class UserServiceTest {
    @Autowired
    private UserService userService;
    
    @Test
    public void testAdd() {
        userService.add("testUser");
    }
}</code></pre>
                    </div>
                </div>
            </div>
        </section>
    </main>

    <!-- Footer -->
    <footer class="bg-gray-900 text-white py-12">
        <div class="container mx-auto px-6">
            <div class="text-center">
                <h3 class="text-xl font-bold mb-4">技术小馆</h3>
                <div class="mb-6">
                    <a href="http://www.yuque.com/jtostring" class="text-gray-400 hover:text-white transition duration-300">
                        <i class="fas fa-globe mr-2"></i>http://www.yuque.com/jtostring
                    </a>
                </div>
                <div class="flex justify-center space-x-6">
                    <a href="#" class="text-gray-400 hover:text-white transition duration-300">
                        <i class="fab fa-github text-xl"></i>
                    </a>
                    <a href="#" class="text-gray-400 hover:text-white transition duration-300">
                        <i class="fab fa-twitter text-xl"></i>
                    </a>
                    <a href="#" class="text-gray-400 hover:text-white transition duration-300">
                        <i class="fab fa-linkedin text-xl"></i>
                    </a>
                </div>
            </div>
            <div class="border-t border-gray-800 mt-8 pt-8 text-center text-gray-400 text-sm">
                <p>© 2023 技术小馆. 保留所有权利.</p>
            </div>
        </div>
    </footer>

    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <script>
        mermaid.initialize({
            startOnLoad: true,
            theme: 'default'
        });
    </script>
</body>
</html>
```